using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

using DataAccess;
using DataTransferObject;

namespace Business
{
    public enum NhaXBBUSResult
    {
        OK,
        MANHAXBCHIERROR,
        TENNHAXBCERROR,
        DAOERROR
    }

    public class clsNhaXBBUS
    {
        //Fields.
        private clsNhaXBDAO NhaXBDAO;

        //Constructors.
        public clsNhaXBBUS()
        {
            this.NhaXBDAO = new clsNhaXBDAO();
        }

        #region Methods

        public NhaXBBUSResult KiemTraRong(clsNhaXBDTO obj)
        {
            if (obj.MaNhaXB == "")
                return NhaXBBUSResult.MANHAXBCHIERROR;
            if ((obj.TenNhaXB == ""))
                return NhaXBBUSResult.TENNHAXBCERROR;
            return NhaXBBUSResult.OK;
        }

        public DataTable DanhSachNhaXB()
        {
            return this.NhaXBDAO.SelectAll();
        }

        public NhaXBBUSResult ThemNhaXB(clsNhaXBDTO obj)
        {
            if (!this.NhaXBDAO.Insert(obj))
                return NhaXBBUSResult.DAOERROR;
            return NhaXBBUSResult.OK;
        }

        public NhaXBBUSResult SuaNhaXB(clsNhaXBDTO obj)
        {
            if (!this.NhaXBDAO.Update(obj))
                return NhaXBBUSResult.DAOERROR;
            return NhaXBBUSResult.OK;
        }

        public NhaXBBUSResult XoaNhaXB(clsNhaXBDTO obj)
        {
            if (!this.NhaXBDAO.Delete(obj))
                return NhaXBBUSResult.DAOERROR;
            return NhaXBBUSResult.OK;
        }
        #endregion
    }
}
